package com.gitee.jjnnzb.designpatterninspring.business.sensitive_word.handler;

import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @author Jjn
 * @since 2023/8/11 11:39
 */
@Component
@RequiredArgsConstructor
public class SensitiveWordChain {
    
    private final List<SensitiveWordFilter> sensitiveWordFilters;
    
    public void filter(Map<String, Object> map) {
        if (CollectionUtils.isNotEmpty(sensitiveWordFilters)) {
            sensitiveWordFilters.forEach(sensitiveWordFilter -> {
                sensitiveWordFilter.filter(map);
            });
        }
    }
    
}
